################################
#
#     Makefile SECONDO ASSEGNAMENTO AA 2018/19
#    
################################


# file da consegnare
# modificare se si aggiungono file
FILE_DA_CONSEGNARE=life.c main.c

# preferenze compilatore e flag di compilazione
CC=gcc
# compilazione 
CFLAGS= -Wall -pedantic -g

obj = life.o life_docenti.o



# phony targets
.PHONY: cleanall test1 test2 test3 consegna 


life0 : 00test.o $(obj)
	gcc $(obj) 00test.o -o life0 -lm

life1 : 01test.o $(obj)
	gcc $(obj) 01test.o -o life1 -lm

life2 : 02test.o $(obj)
	gcc $(obj) 02test.o -o life2 -lm

life3 : 03test.o $(obj)
	gcc $(obj) 03test.o -o life3 -lm

life4 : 04test.o $(obj)
	gcc $(obj) 04test.o -o life4 -lm

life0 : 00test.o $(obj)
	gcc $(obj) 00test.o -o life0 -lm



life.o: life.c life.h  
life.o: life.c life.h  
00test.o: 00test.c life.h   
01test.o: 01test.c life.h   
02test.o: 02test.c life.h   
03test.o: 03test.c life.h   
04test.o: 04test.c life.h   

life: $(obj) main.o
	gcc $(obj) main.o -o life -lm


cleanall: 
	-rm -f *.o *~ ./core life? life


test0:
	rm -f ./input2 ./input3 ./out2* ./out3*
	make cleanall
	make life0
	./life0
	@echo "********** Test superato!"

test1:
	make cleanall
	make life1
	./life1 
	@echo "********** Test1 superato!"

test2: 
	rm -f ./input1
	cp DATA/input1 .
	make cleanall
	make life2
	./life2
	diff ./input1 ./out1
	@echo "********** Test2 superato!"

test3:
	rm -f ./input2 ./input3 ./out2* ./out3*
	cp DATA/input2 DATA/input3 DATA/out2.check DATA/out3.check .
	make cleanall
	make life3
	./life3
	diff out2 out2.check
	diff out3 out3.check
	@echo "********** Test3 superato!"


test4: 
	make cleanall
	rm -f in.txt out.txt
	make life
	./life
	ls in.txt
	ls out.txt
	@echo "********** Test4 superato!"



test5: 
	rm -f ./input2 ./input3 ./out2* ./out3*
	cp DATA/input2 DATA/input3 DATA/out2.check DATA/out3.check .
	make cleanall
	rm -f in.txt out.txt
	make life
	./life input2 -s 3
	diff out.txt out2.check
	./life input3 -s 10
	diff out.txt input3
	@echo "********** Test5 superato!"


consegna:
	make cleanall
	make test1
	make test2
	make test3
	make test4
	./gruppo-check.pl < gruppo.txt
	tar -cvf $(USER)-ar.tar ./gruppo.txt  $(FILE_DA_CONSEGNARE) 
	@echo "********** TAR creato inviare in allegato a una mail al docente del proprio corso insieme a nome, cognome,  numero di matricola dei componenti del gruppo"
